package com.surprise.db.dao.join;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.surprise.db.dao.SimpleDAO;
import com.surprise.db.entity.join.SelectUserRelation001Entity;

/**
 * SelectUserRelation001.java
 * @author xuling
 * @since 2017年2月14日
 */
@Repository
public class SelectUserRelation001 extends SimpleDAO<SelectUserRelation001Entity> {

	/**
	 * 获得已关注的用户
	 * @param userid 用户ID
	 * @return 已关注的用户信息
	 */
	public List<SelectUserRelation001Entity> select(Long userid) {
		String sql = " SELECT user_relation.id, user_relation.userid as userid, " + 
				"user_relation.friendid as friendid, user.username, " + 
				"user.portrait FROM user_relation INNER JOIN user ON user.id = user_relation.friendid " +
				"WHERE user_relation.userid = ? and user_relation.deleteflg = 0";
		return super.findBySql(sql, userid);
	}
}
